package ar.com.sne.model.bo.geo;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.log4j.Logger;

import ar.com.sne.bean.BaseBO;
import ar.com.sne.model.bo.per.PerPersona;
import ar.com.sne.model.dao.factory.GeoDAOFactory;

/**
 * GeoMail
 * Clase encargada de encapsular la logica de geografia para mails.
 */

@Entity
@Table(name = "GEO_MAILS", catalog = "sneweb")
public class GeoMail extends BaseBO {

	private GeoTipoMail geoTipoMails;
	private PerPersona perPersonas;
	private String direccion;

	@Transient
	Logger log = Logger.getLogger(GeoMail.class);

	/*
	 * Contructores 
	 */
	
	public GeoMail() {
		super();
	}
	
	/*
	 * Getter & Listters
	 */

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_tipo_mail", nullable = false)
	public GeoTipoMail getGeoTipoMails() {
		return this.geoTipoMails;
	}

	public void setGeoTipoMails(GeoTipoMail geoTipoMails) {
		this.geoTipoMails = geoTipoMails;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_persona", nullable = false)
	public PerPersona getPerPersonas() {
		return this.perPersonas;
	}

	public void setPerPersonas(PerPersona perPersonas) {
		this.perPersonas = perPersonas;
	}

	@Column(name = "direccion", nullable = false, length = 100)
	public String getDireccion() {
		return this.direccion;
	}

	public void setDireccion(String direccion) {
		this.direccion = direccion;
	}
	
	/*
	 * Metodos de Clase
	 */
	
	public static GeoMail getById(Long id){
		return (GeoMail) GeoDAOFactory.getGeoMailDAO().getById(id);
	}
	
	public static GeoMail getByIdNull(Long id) {
		return (GeoMail) GeoDAOFactory.getGeoMailDAO().getByIdNull(id);
	}
	
	public static List<GeoMail> getList() {
		return (List<GeoMail>) GeoDAOFactory.getGeoMailDAO().getList();
	}
	
	public static List<GeoMail> getListActivos() {			
		return (List<GeoMail>) GeoDAOFactory.getGeoMailDAO().getListActiva();
	}
}
